package com.itheima.pattern.singleton.demo3;

/**
 * 懒汉式
 */
public class Singleton {
    // 私有化构造方法
    private Singleton() {}

    private static Singleton instance; // 为null

    // 声明Singleton类型的变量Instance
    public static synchronized Singleton getInstance() {
        if(instance == null) {
            instance = new Singleton();
        }
        return instance;

    }
}
